02. Extending your Robot Creation - Sensor Upgrade

Sensor Upgrades

The recommended configuration for RTAB-Map is as follows:

You may notice that a 2D laser scanner is listed and although it is recommended, it is not required. We will touch more on that shortly.

RTAB-Map Quick Sensor Overview

When building your ROS package you will need to make sure that you are publishing the right information for RTAB-Map to successfully work. In the image below you can get a visual overview of the high level connections enabling both mapping and localization.

Before we move to how we are going to update our robot with an RGB-D camera, let's touch on how you could set up your robot (simulated and real) with just an RGB-D camera. Removing the laser scanner does not mean that we no longer need the scan topic, but that we need to find a new way to generate this scan topic. This is where the depthimage_to_laserscan package for the Kinect comes in. This package illustrates and provides a method of mapping the depth point cloud into a usable scan topic. This remapping can be viewed in the image below.

This is a convenient solution for those without a laser scanner on their robot. Since we are upgrading our robot from the previous project, we will elect to keep the laser range finder and the scan topic it provides and sticking with RTAB-Maps optimal configuration.

Furthermore, it can be noted that the scan input topic is a convenient way to efficiently create an occupancy grid based on 2D ray tracing. However, you can achieve the same results with depth image, but it is more costly to generate.

Configuring the RGB-D Camera

In the previous project you constructed an RGB camera, now it's time to give that an upgrade. Specifically, we will simulate a Kinect camera.

To do this we will need to replace the existing camera and its shared object file: libgazebo_ros_camera.so to that off the Kinect shared object file: libgazebo_ros_openni_kinect.so. On top of this, additional parameters need to be set for the RGB-D camera as well as matching the topics published by the drivers of its real world counterpart. We have provided an example for the camera code below:

<!-- RGBD Camera -->
  <gazebo reference="camera_link">
    <sensor type="depth" name="camera1">
        <always_on>1</always_on>
        <update_rate>20.0</update_rate>
        <visualize>true</visualize>             
        <camera>
            <horizontal_fov>1.047</horizontal_fov>  
            <image>
                <width>640</width>
                <height>480</height>
                <format>R8G8B8</format>
            </image>
            <depth_camera>

            </depth_camera>
            <clip>
                <near>0.1</near>
                <far>20</far>
            </clip>
        </camera>
             <plugin name="camera_controller" filename="libgazebo_ros_openni_kinect.so">
             <alwaysOn>true</alwaysOn>
                <updateRate>10.0</updateRate>
                <cameraName>camera</cameraName>
                <frameName>camera_rgbd_frame</frameName>                   
            <imageTopicName>rgb/image_raw</imageTopicName>
            <depthImageTopicName>depth/image_raw</depthImageTopicName>
            <pointCloudTopicName>depth/points</pointCloudTopicName>
            <cameraInfoTopicName>rgb/camera_info</cameraInfoTopicName>              
            <depthImageCameraInfoTopicName>depth/camera_info</depthImageCameraInfoTopicName>            
            <pointCloudCutoff>0.4</pointCloudCutoff>                
                <hackBaseline>0.07</hackBaseline>
                <distortionK1>0.0</distortionK1>
                <distortionK2>0.0</distortionK2>
                <distortionK3>0.0</distortionK3>
                <distortionT1>0.0</distortionT1>
                <distortionT2>0.0</distortionT2>
            <CxPrime>0.0</CxPrime>
            <Cx>0.0</Cx>
            <Cy>0.0</Cy>
            <focalLength>0.0</focalLength>
            </plugin>
    </sensor>
  </gazebo>

You may use the provided code, but you will need to make sure that you adjust for the required linkages in your URDF. Furthermore, you will need to be sure that you are publishing the correct topics and using the proper naming conventions. You will be taught some debugging techniques to help locate issues and resolve them in the upcoming concepts.

Further Resources: Gazebo RGB-D Camera Information